﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package net.wooga.pets.controllers.data {
    import flash.events.*;
    import net.wooga.pets.events.*;
    import net.wooga.pets.models.*;
    import net.wooga.pets.constants.*;
    import org.robotlegs.mvcs.*;
    import net.wooga.pets.models.fountain.*;
    import net.wooga.pets.services.*;
    import net.wooga.pets.models.world.*;

    public class StoreStartDataCommand extends Command {

		[Inject]
        public var event:InfoEvent;
		[Inject]
        public var sessionModel:SessionModel;
		[Inject]
        public var userModel:UserModel;
		[Inject]
        public var energyModel:EnergyModel;
		[Inject]
        public var roomSlotsModel:RoomSlotsModel;
		[Inject]
        public var missions:MissionModel;
		[Inject]
        public var tutorial:TutorialModel;
		[Inject]
        public var social:ISocialNetworkService;
		[Inject]
        public var symbols:SymbolModel;
		[Inject]
        public var inventoryModel:InventoryModel;
		[Inject]
        public var achievementModel:AchievementModel;
		[Inject]
        public var soundService:SoundService;
		[Inject]
        public var shopModel:ShopModel;
		[Inject]
        public var worldModel:WorldModel;
		[Inject]
        public var collectableModel:CollectableModel;

        override public function execute():void{
            var _local2:int;
            var _local1:Object = this.event.info;
            this.roomSlotsModel.initialize();
            this.roomSlotsModel.availableRoomSlotsNumber = _local1.level_info.room_slots;
            this.sessionModel.data = _local1;
            this.sessionModel.timestamp = _local1.timestamp;
            this.sessionModel.session_id = _local1.session_id;
            this.sessionModel.inventoryItems = _local1.inventory_items;
            this.sessionModel.slotMachineInventoryItems = _local1.items;
            this.sessionModel.savepoints = _local1.savepoints;
            this.sessionModel.currentRooms = _local1.rooms;
            this.sessionModel.readLetters = ((_local1.read_letters) || ([]));
            this.sessionModel.availableRoomTypes = _local1.level_info.room_types;
            this.sessionModel.currentPets = _local1.pets;
            this.sessionModel.currentAvatar = _local1.avatar;
            this.sessionModel.levelInfo = _local1.level_info;
            this.sessionModel.doctorMealDuration = _local1.doctor_meal_duration;
            this.sessionModel.babyHugDuration = _local1.baby_hug_duration;
            this.sessionModel.requestLimits = _local1.request_limits;
            this.sessionModel.surprisePackages = _local1.surprises;
            this.sessionModel.viewedDiseaseStorys = _local1.level_info.cured_diseases;
            this.userModel.coins = _local1.coins;
            this.userModel.xpPoints = _local1.xp;
            this.userModel.setLevel(_local1);
            this.userModel.xpBounds = _local1.level_info.xp_bounds;
            this.userModel.newUser = _local1.new_user;
            this.userModel.batteries = _local1.batteries;
            this.userModel.coffee = _local1.coffee;
            this.userModel.goods = _local1.goods;
            this.userModel.numberOfCuredPets = ((_local1.level_info.number_of_cured_pets) || (0));
            this.userModel.numberOfBirdsCollected = ((_local1.level_info.number_of_birds_collected) || (0));
            this.userModel.numberOfUsedEnergy = ((_local1.level_info.amount_of_used_energy) || (0));
            this.userModel.numberOfFedDoctors = ((_local1.level_info.number_of_fed_doctors) || (0));
            this.userModel.numberOfCuredElders = ((_local1.level_info.number_of_cured_elders) || (0));
            this.userModel.numberOfCollectedSymbols = ((_local1.level_info.number_of_collected_symbols) || (0));
            this.achievementModel.collectedRewardIDs = _local1.level_info.completed_achievements;
            this.shopModel.integrateStoredItems(_local1.stored_elements);
            if (_local1.hasOwnProperty("energy")){
                this.energyModel.energyStartedAt = _local1.energy.started_at;
                this.energyModel.energyUsed = _local1.energy.used;
                this.energyModel.energyMax = _local1.energy.max_value;
                this.energyModel.energyRefillDuration = _local1.energy.refill_duration;
                this.energyModel.boostDuration = _local1.energy.boost_duration;
                this.energyModel.energyExtra = _local1.energy.extra;
                this.energyModel.startDifferenceCounter();
            };
            if (_local1.mission){
                this.missions.addDefaultMission(_local1.mission);
            };
            if (_local1.hasOwnProperty("level_missions")){
                this.missions.addLevelMissions(_local1.level_missions);
            };
            if (_local1.hasOwnProperty("queue")){
                for each (_local2 in _local1.queue) {
                    this.worldModel.addToWaitingQueue(_local2);
                };
            };
            if (this.social.isConnected){
                dispatch(new Event(EventConstants.LOAD_DETAILS));
            };
            if (_local1.collectables){
                this.collectableModel.addCollectables(_local1.collectables);
            };
            this.symbols.symbols = _local1.symbols;
            dispatch(new InfoEvent(EventConstants.INIT_TREE, null, _local1.tree));
            this.inventoryModel.inventory = _local1.inventory;
            this.soundService.musicMuted = !(_local1.sound);
            this.soundService.effectsMuted = !(_local1.effects);
            dispatch(new Event(EventConstants.INIT_GAME));
        }
        private function createTestSurpriseData():Array{
            var _local1:Array = [];
            return (_local1);
        }

    }
}//package net.wooga.pets.controllers.data 
